#ifndef _PCAM_USB_H
#define _PCAM_USB_H

#include "includes_fw.h"
#include "mmpf_typedef.h"
#include "pcam_api.h"

#define CALI_TABLE_AUTO    0x00 //Use Cali table first if it's valid
#define CALI_TABLE_DEFAULT 0x01 //Force to use default tables in IQ table
#define CALI_TABLE_CALI    0x02 //Force use Cali table
extern MMP_UBYTE gbTableUsed;
#define CALI_TABLE_UNDEFINED 0xFF
extern MMP_UBYTE gbTestCaliTable;

MMP_BOOL   USB_IsPreviewActive(void);
MMP_USHORT USB_VideoPreviewStart(MMP_USHORT nonblocking);
MMP_USHORT USB_ForceH264IDRFrame(void);
MMP_USHORT USB_VideoPreviewStop(MMP_USHORT nonblocking);
MMP_USHORT USB_VideoPowerDown(MMP_USHORT nonblocking);
MMP_USHORT USB_AudioPreviewStart(MMP_USHORT nonblocking);
MMP_USHORT USB_AudioPreviewStop(MMP_USHORT nonblocking);
MMP_USHORT USB_SetSaturation(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetContrast(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetBrightness(MMP_USHORT nonblocking,MMP_SHORT val);
MMP_USHORT USB_SetHue(MMP_USHORT nonblocking,MMP_SHORT val);
MMP_USHORT USB_SetGamma(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetBacklight(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetSharpness(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetLensPosition(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_EnableAF(MMP_USHORT nonblocking,MMP_BOOL val);
MMP_USHORT USB_EnableAE(MMP_USHORT nonblocking,MMP_BOOL val);
MMP_USHORT USB_SetAEExposureValue(MMP_USHORT nonblocking,MMP_ULONG val);
MMP_USHORT USB_SetAWBMode(MMP_USHORT nonblocking,MMP_UBYTE val);
MMP_USHORT USB_SetAWBTemp(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetPowerLineFreq(MMP_USHORT nonblocking,MMP_UBYTE val);
MMP_USHORT USB_SetGain(MMP_USHORT nonblocking,MMP_USHORT val);
MMP_USHORT USB_SetH264Resolution(MMP_USHORT nonblocking,PCAM_USB_VIDEO_RES pCamRes);
MMP_USHORT USB_SetVideoFormat(MMP_USHORT nonblocking,PCAM_USB_VIDEO_FORMAT pCamVidFmt);
MMP_USHORT USB_SetVideoQuality(MMP_USHORT nonblocking,PCAM_USB_VIDEO_QUALITY pCamQ);
MMP_USHORT USB_SetVideoResolution(MMP_USHORT nonblocking,PCAM_USB_VIDEO_RES pCamRes);
void USB_LEDDisplay(MMP_UBYTE num, MMP_UBYTE status) ;
void USB_WriteI2C(MMP_USHORT addr, MMP_USHORT val,MMP_UBYTE mode);
MMP_USHORT USB_ReadI2C(MMP_USHORT addr,MMP_UBYTE mode);
MMP_USHORT USB_UpdateFirmware(MMP_USHORT nonblocking,MMP_USHORT step) ; 
MMP_USHORT USB_CheckTaskAlive(MMP_USHORT heartbeat);
#if 0
MMP_USHORT USB_SetDigitalZoom(MMP_USHORT nonblocking,MMP_UBYTE dir,MMP_UBYTE range_min,MMP_UBYTE range_max,MMP_UBYTE range_step);
#else
__inline MMP_USHORT USB_SetDigitalZoom(MMP_USHORT nonblocking,MMP_UBYTE dir,MMP_UBYTE range_min,MMP_UBYTE range_max,MMP_UBYTE range_step)
{
    PCAM_USB_ZOOM val ;
    //RTNA_DBG_Str(3,"USB_SetDigitalZoom\r\n");

    val.Dir = dir ;
    val.RangeMin = range_min ;
    val.RangeMax = range_max ;
    val.RangeStep = range_step;
    pcam_usb_set_nonblocking(nonblocking);
    return pcam_usb_set_attributes(PCAM_USB_SETTING_DIGZOOM,&val);
}
#endif
MMP_USHORT USB_SetDigitalPanTilt(MMP_USHORT nonblocking,MMP_LONG pan_min,MMP_LONG pan_max,MMP_LONG tilt_min,MMP_LONG tilt_max,MMP_USHORT total_step);
MMP_USHORT USB_TakeRawPicture(MMP_USHORT nonblocking,MMP_ULONG addr) ;
MMP_USHORT USB_AudioSetMute(MMP_USHORT nonblocking,MMP_BOOL mute) ;
MMP_USHORT USB_AudioSetVolume(MMP_USHORT nonblocking,MMP_SHORT vol);
MMP_USHORT USB_AudioSetSampleRate(MMP_USHORT nonblocking,MMP_ULONG sample_rate);
MMP_USHORT USB_SetAsyncVideoControl(MMP_UBYTE bOriginator,MMP_UBYTE bSelector,MMP_UBYTE bAttribute,MMP_UBYTE bValUnit);
MMP_USHORT USB_AudioReset(MMP_USHORT nonblocking);
MMP_USHORT USB_SetAudioMode(MMP_USHORT nonblocking,MMP_UBYTE mode);
PCAM_BAYER_INFO *USB_GetBayerRawInfo(void);
void USB_EnableBayerRawPreview(MMP_BOOL enable);
MMP_BOOL USB_IsBayerRawPreview(void);

#endif
